<?php

namespace app\api\admin;

use extend\bridgeserv\BridgeServerProxy;
use zhanshop\App;

class HttpProxyEvent
{
    /**
     * @param \Swoole\Server $server
     * @param int $fd
     * @param int $reactorId
     * @return void
     */
    public function onConnect($server, $fd, $reactorId) :void{
        $server->bind($fd, $fd);
    }

    /**
     * @param \Swoole\Server $server
     * @param int $fd
     * @param int $reactorId
     * @param string $data
     * @return void
     */
    public function onReceive($server, $fd, $reactorId, $data) :void{
        App::make(BridgeServerProxy::class)->httpMessage($server, $fd, $data);
    }

    /**
     * 关闭消息
     * @param \Swoole\Server $server
     * @param int $fd
     * @return void
     */
    public function onClose($server, $fd) :void{
        App::make(BridgeServerProxy::class)->httpClose($server, $fd);
    }
}